var categoryManager = function() {
	this.INPUTs = null;
    this.DATEs = null;
    this.SELECTs = null;    
    this.NUMBERs = null;
    this.BUTTONs = null;

    // key down textbox
    this.txtKeyDown = function (e) {    	
        // Allow: backspace, delete, tab, escape, and enter
    	var event = e;
        if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9
		    || event.keyCode == 27 || event.keyCode == 13 ||
        // Allow: Ctrl+A
		    (event.keyCode == 65 && event.ctrlKey === true) ||
        // Allow: home, end, left, right
		    (event.keyCode >= 35 && event.keyCode <= 39)) {
            // let it happen, don't do anything
            return;
        }
        // Allow: .
        else if (event.keyCode == 190) {
        	var idElement = "";
        	var ua = $.browser;
            if (!ua.mozilla) idElement = event.srcElement.id;
            else idElement = event.target.id;
            var objElement = document.getElementById(idElement);
            var sText = objElement.value;
            var isDecimal = objElement.getAttribute("IsDecimal");
            if ((sText.indexOf('.') == -1) && (isDecimal == 1)
			    && (sText.length > 0))
                return;
            else
                event.preventDefault();
        } else {
            // Ensure that it is a number and stop the keypress
            if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57)
			    && (event.keyCode < 96 || event.keyCode > 105)) {
                event.preventDefault();
            }
        }
    };
    
    this.init = function(categoryOBJ)
    {
    	for (var i = 0; i < this.INPUTs.length; i++) {
            var $target = $(this.INPUTs[i]);
            $target.attr('disabled', false);
            $target.val("");
        }      
		
        for(var i = 0; i<this.SELECTs.length; i++) {
        	var $target = $(this.SELECTs[i]);
            $target.val("");
        }
        
        for (var i = 0; i < this.DATEs.length; i++) {
            var $target = $(this.DATEs[i]);
            $target.val("");            
            $target.datepicker({
                numberOfMonths: 1,
                constrainInput: true,
                dateFormat: 'dd/mm/yy',
                showButtonPanel: false,
                hideIfNoPrevNext: true,
                autoSize: false,
                onSelect: function (date) {                	
                }
            });
        }

        for (var i = 0; i < this.NUMBERs.length; i++) {
            var $target = $(this.NUMBERs[i]);
            $target.keydown(function (e) {
            	var targetELement = e;
                categoryOBJ.txtKeyDown(targetELement);
            });
        }
    };
};
var categoryOBJ = new categoryManager();
categoryOBJ.init(categoryOBJ);